﻿using System;
using System.Collections.Generic;
using System.Text;
using Htinns.PMS.Entity.Base;
using Htinns.PMS.DAL.Base;

namespace Htinns.PMS.DAL.MapperService
{
    public interface IMapperService
    {

        /// <summary>
        /// 添加一个实体类到数据库
        /// </summary>
        /// <param name="entity">欲添加到数据库的实体类</param>
        void Add(IEntity entity);

        void Add(IEntity entity, object[] args);

        /// <summary>
        /// 删除一个实体类
        /// </summary>
        /// <param name="entity">欲删除的实体类</param>
        void Delete(IEntity entity);

        void Delete(IEntity entity, object[] args);

        /// <summary>
        /// 更新一个实体类
        /// </summary>
        /// <param name="entity">欲删出的实体类</param>
        void Update(IEntity entity);

        void Update(IEntity entity, object[] args);

        IEntity Get(Type entityType, object[] keys);

        IDelayEntity Get(Type entityType, object[] keys, bool isLazy);

        /// <summary>
        /// 添加一批实体类到数据库
        /// </summary>
        /// <param name="entity">欲添加到数据库的实体类集合</param>
        void BatchAdd(Type entityType, IEnumerable<IEntity> entity);

        void BatchAdd(Type entityType, IEnumerable<IEntity> entity, object[] args);

        /// <summary>
        /// 从数据库删除一批实体类
        /// </summary>
        /// <param name="entity">欲从数据库删除的实体类集合</param>
        void BatchDelete(Type entityType, IEnumerable<IEntity> entity);

        void BatchDelete(Type entityType, IEnumerable<IEntity> entity, object[] args);

        /// <summary>
        /// 向数据库更新一批实体类
        /// </summary>
        /// <param name="entity">欲更新到数据库的实体类集合</param>
        void BatchUpdate(Type entityType, IEnumerable<IEntity> entity);

        void BatchUpdate(Type entityType, IEnumerable<IEntity> entity, object[] args);

        /// <summary>
        /// 从数据库读取一批实体类
        /// </summary>
        /// <param name="entityType">欲获取的实体类的类型</param>
        /// <param name="keys">指定的参数</param>
        /// <returns>获取的实体类集合</returns>
        IEnumerable<IEntity> BatchGet(Type entityType, object[] keys);

        void SynchronizeField(IDelayEntity entity, string[] indexs); 

        /// <summary>
        /// 加载属性
        /// </summary>
        /// <param name="entity">欲加载属性的实体类对象集合</param>
        /// <param name="indexs">欲加载的属性名列表</param>
        void SynchronizeField(Type entityType, IEnumerable<IDelayEntity> entity, string[] indexs);

        IEnumerable<IDelayEntity> BatchGet(Type entityType, object[] key, bool isLazy);
    }
}
